<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions" 
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:activiti="http://activiti.org/bpmn"
  targetNamespace="Examples">
  
  <process id="SubprocessParallelThrowCompensationScenario" isExecutable="true">
    <startEvent id="start" />
    
    <sequenceFlow sourceRef="start" targetRef="subProcess" />
    <subProcess id="subProcess">
      <startEvent id="subProcessStart" />
      <sequenceFlow sourceRef="subProcessStart" targetRef="userTask" />
      <userTask id="userTask"/>
      <sequenceFlow sourceRef="userTask" targetRef="subProcessEnd" />
      <endEvent id="subProcessEnd" />
  
      <!-- compensation -->
      <boundaryEvent id="compensateBoundaryEvent" attachedToRef="userTask">
        <compensateEventDefinition />
      </boundaryEvent>
      <userTask id="undoTask" isForCompensation="true"/>
    
      <association associationDirection="One" sourceRef="compensateBoundaryEvent" targetRef="undoTask" />
    </subProcess>

    <sequenceFlow sourceRef="subProcess" targetRef="fork" />
    <parallelGateway id="fork" />
    <sequenceFlow sourceRef="fork" targetRef="beforeCompensate" />
    <userTask id="beforeCompensate" />
    <sequenceFlow sourceRef="beforeCompensate" targetRef="throwCompensate" />
    
    <intermediateThrowEvent id="throwCompensate">
      <compensateEventDefinition />
    </intermediateThrowEvent>
    
    <sequenceFlow sourceRef="throwCompensate" targetRef="afterCompensate" />
    <userTask id="afterCompensate" />
    <sequenceFlow sourceRef="afterCompensate" targetRef="end" />
    <endEvent id="end" />
    
    <!-- concurrent branch with a single wait state -->
    <sequenceFlow sourceRef="fork" targetRef="concurrentTask" />
    <userTask id="concurrentTask" />
    <sequenceFlow sourceRef="concurrentTask" targetRef="end" />
    
  </process>
</definitions>
